<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 인기 스타 관리 컨트롤러
 */
class Popular extends CI_Controller {
	
	var $data = array();
	
	function __construct() {
		parent::__construct();

		$this->load->model('star/Popular_model', 'star');
	}
	
	// Default
	function index() {
		$this->popular_list();
	}
	
	/**
	 * 이달의 스타 리스트
	 */
	function popular_list() {
		log_message('debug', "@@@@ Popular::popular_list()");
		
		$this->data['list'] = $this->star->select_popular_star_list('main_monthly');
		
		$this->load->view('star/popular_list_v', $this->data);
	}	
	
	/*******************************************************************
	 * 삭제
	 *******************************************************************/
	function remove_ok() {
		log_message('debug', "@@@@ Popular::remove_ok()");
		
		$artist_idx  = $this->input->post('artist_idx');
		$popular_id  = $this->input->post('popular_id');
		$this->star->delete_popular_star($popular_id, $artist_idx);
		echo "<script type='text/javascript'>alert('삭제완료');location.href='/star/popular';</script>";
	}
	
	/*******************************************************************
	 * 인기스타 추가 처리
	 *******************************************************************/
	function write_ok() {
		log_message('debug', "@@@@ Popular::write_ok()");

		$artist_idx  = $this->input->post('artist_idx', TRUE);
		$artist_name = $this->input->post('artist_name', TRUE);
		$priority    = $this->input->post('priority', TRUE);
		$popular_id  = $this->input->post('popular_id', TRUE);
		
		$this->star->insert_popular_star($popular_id, $artist_idx, $artist_name, $priority);
		
		redirect("/star/popular");
	}

}


/* End of file starpt.php */
/* Location: ./application/controllers/star/starpt.php */